<%-- 
    Document   : coursefiles
    Created on : 10-jan-2013, 9:35:27
    Author     : kjeld
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="/style/general.css" type="text/css" rel="Stylesheet">
        <link rel="stylesheet" href="/style/slideshow.css" />
        <!-- include jQuery Library From Google Code -->
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
        <script src="/js/dynamic-controls-bootstrap.js"></script>
        <script type="text/javascript">
            var descriptions = new Array();
            <c:forEach var="description" items="${descriptions}">
                var description = new Object();
                description.fileName = "${description.fileName}";
                description.fileDescription = "${description.fileDescription}";
                descriptions.push(description);
            </c:forEach>
                function fileInfo(filename){
                    for(var i=0; i<descriptions.length; i++) {
                        
                        var value = descriptions[i].fileName;
                        if(value == filename){
                            alert(descriptions[i].fileDescription);
                            break;
                        }
                    }
                    
                }
        </script>

        <jsp:useBean id="inhoud" scope="application" class="models.Bean" />   
        <jsp:setProperty name="inhoud" property="language" value="<%= models.Bean.getLanguage()%>" />

        <title>
            Three 2 Learn | files
        </title>
        <!-- The main style sheet -->
        <link rel="stylesheet" href="/style/login.css" type="text/css" media="screen" />

        <!-- START Fx.Slide -->
        <!-- The CSS -->
        <link rel="stylesheet" href="/style/fx.slide.css" type="text/css" media="screen" />
        <!-- Mootools - the core -->
        <script type="text/javascript" src="/js/mootools-1.2-core-yc.js"></script>
        <!--Toggle effect (show/hide login form) -->
        <script type="text/javascript" src="/js/mootools-1.2-more.js"></script>
        <script type="text/javascript" src="/js/fx.slide.js"></script>
        <!-- END Fx.Slide -->
    </head>
    <body>
        <div id="container">

            <div id="wrapper">
                <div id="header">
                    <div id="topmenu">
                        <ul class="login">
                            <li><img src="/style/logo32L.png"/></li>
                            <li><a href="/language?lang=nl" title="Nederlands"><img src="/images/flags/nl.png"></a></li>
                            <li><a href="/language?lang=en" title="English"><img src="/images/flags/uk.png"></a></li>

                            <c:choose>
                                <c:when test="${loggedin eq 'true'}">
                                    <li><a href="/logout" id="toggleLogout" >
                                            <jsp:setProperty name="inhoud" property="key" value="LogOut" />
                                            <jsp:getProperty name="inhoud" property="key" />
                                        </a></li>
                                    <li><a href="/${omgeving}" >
                                            <jsp:setProperty name="inhoud" property="key" value="BackTo" />
                                            <jsp:getProperty name="inhoud" property="key" /> ${omgeving}
                                            <jsp:setProperty name="inhoud" property="key" value="TheEnvironment" />
                                            <jsp:getProperty name="inhoud" property="key" />
                                        </a></li>
                                    <li><h2><jsp:setProperty name="inhoud" property="key" value="Welcome" />
                                            <jsp:getProperty name="inhoud" property="key" />, ${user.firstName} ${user.lastName}</h2></li>
                                </c:when>
                                    <c:otherwise>
                                    <li><a href="#" id="toggleLogin" >
                                            <jsp:setProperty name="inhoud" property="key" value="Login" />
                                            <jsp:getProperty name="inhoud" property="key" />
                                        </a></li>
                                    </c:otherwise>
                                </c:choose>

                        </ul>
                    </div>
                    <div class="middle">
                        <div id="menu">
                            <ul>
                                <li><a href="/index.jsp">
                                        <jsp:setProperty name="inhoud" property="key" value="Homepage" />
                                        <jsp:getProperty name="inhoud" property="key" />
                                    </a></li>
                                <li><a href="/courses">
                                        <jsp:setProperty name="inhoud" property="key" value="Courses" />
                                        <jsp:getProperty name="inhoud" property="key" />
                                    </a></li>
                                <li><a href="three2Learn.jsp">Three2Learn</a></li>
                                <li><a href="information.jsp">
                                        <jsp:setProperty name="inhoud" property="key" value="Information" />
                                        <jsp:getProperty name="inhoud" property="key" /></a></li>
                                <li><a href="faq.jsp">
                                        <jsp:setProperty name="inhoud" property="key" value="FAQ" />
                                        <jsp:getProperty name="inhoud" property="key" /></a></li>
                                </a></li>
                                <li><a href="contact.jsp">Contact</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div id="context">
                    <table>
                    <th colspan="3"><a href="/studentcourse?courseID=${course.courseID}">
                        <jsp:setProperty name="inhoud" property="key" value="BackToOverview" />
                        <jsp:getProperty name="inhoud" property="key" />
                        </a>                                     
                        </th></table>

                        <div>
                            <h2><jsp:setProperty name="inhoud" property="key" value="UploadFile" />
                                <jsp:getProperty name="inhoud" property="key" /></h2>

                            <form action="/studentcourse/files" method="post"
                                  enctype="multipart/form-data">
                                <table>
                                    <th colspan="2"><jsp:setProperty name="inhoud" property="key" value="ChooseAFile" />
                                        <jsp:getProperty name="inhoud" property="key" /></th>
                                    <tr>
                                        <td>
                                            <jsp:setProperty name="inhoud" property="key" value="Description" />
                                            <jsp:getProperty name="inhoud" property="key" />
                                            :
                                            <input type="text" id="description" name="description" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="file" name="file" size="50" accept=".pdf" />
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>
                                            <input type="submit" value="Upload File" />
                                        </td>
                                    </tr>
                                </table>
                            </form>

                        </div>
                                            <div>
                                                <p><h2>Modulebeschrijving:</h2><br/>${folderdescription}</p>
                                            </div>
                        <div id="files">
                            <h2>Browser</h2>
                            <!--<h2></h2>
                            <p><a href="#" onclick="newFolder();">create new folder</a></p>!-->
                            <table width="100%" id="filetable">
                                <th colspan="3"><jsp:setProperty name="inhoud" property="key" value="Location" />
                                    <jsp:getProperty name="inhoud" property="key" />: ${foldername}${subfolder}

                                     
                                </th>
                                <c:if test="${subfolder != ''}">                                    
                                    <tr>
                                        <td> 
                                            <img height="40px" src="/images/foldericon.png" />
                                        </td>
                                        <td  style="width:90%;">
                                            <p align="center"><a href="/studentcourse/files?courseID=${courseID}&selectedfile=..">..</a></p>
                                        </td><td></td>
                                    </tr>
                                </c:if>
                                <c:forEach var="directory" items="${directories}">
                                    <tr>
                                        <td>
                                            <img height="40px" src="/images/foldericon.png" />
                                        </td>
                                        <td style="width:90%;">
                                            <p align="center"><a href="/studentcourse/files?courseID=${courseID}&selectedfile=${directory.name}">${directory.name}</a></p>
                                        </td><td></td>
                                    </tr>
                                </c:forEach>
                                <c:forEach var="file" items="${files}">
                                    <tr>
                                        <c:set var="fileExtension" value="fileicon.png"/>
                                        <c:if test="${fn:contains(file.name, '.ppt')}">
                                            <c:set var="fileExtension" value="ppticon.png"/>
                                        </c:if>
                                        <c:if test="${fn:contains(file.name, '.doc')}">
                                            <c:set var="fileExtension" value="docicon.jpg"/>
                                        </c:if>
                                        <c:if test="${fn:contains(file.name, '.pdf')}">
                                            <c:set var="fileExtension" value="pdficon.jpg"/>
                                        </c:if>
                                        <c:if test="${fn:contains(file.name, '.txt')}">
                                            <c:set var="fileExtension" value="txticon.gif"/>
                                        </c:if>
                                        <c:if test="${fn:contains(file.name, '.zip')}">
                                            <c:set var="fileExtension" value="zipicon.jpg"/>
                                        </c:if>

                                        <td><img height="40px" src="/images/${fileExtension}" />
                                        </td>
                                        <td width="800px">
                                            <p align="center">${file.name}</p>
                                        </td>
                                        <td>
                                            <a href="#" onclick="fileInfo('${file.name}');"><img height="20" src="/images/info.png"/></a>
                                        </td>
                                        <td>
                                            <a href="/studentcourse/files?courseID=${courseID}&selectedfile=${file.name}">Download</a>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </table>
                            <input type="hidden" name="subfolder" id="subfolder" value="${subfolder}"></input>
                        </div>
                    </div>
                </div>
            
        </div>
    </body>
</html>
